﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.FSharp.Core;

namespace Cephei.Core
{
    namespace Generic
    {
        /// <summary>
        /// Provide a Contravariant interface for casting assignement
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public interface IValueCell<in T> : ICell
        {
            /// <summary>
            /// Content of the Cell
            /// </summary>
            T Content { set; }
        }
        /// <summary>
        /// Provide a CoVariant interface for casting assignement
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public interface ICoCell<out T> : ICell
        {
            /// <summary>
            /// interface to set the value of the cell
            /// </summary>
            T Value { get; }
            /// <summary>
            /// Historical value for the trade at the transaction time
            /// </summary>
            /// <param name="epoch">the timepoint for the transaction</param>
            /// <returns>the value</returns>
            T ValueAt (DateTime epoch);
            /// <summary>
            /// get the historical value from the cell <b>and</b> remove the history
            /// </summary>
            /// <param name="epoch">the timepoint for the transaction</param>
            /// <returns>the value</returns>
            T TakeAt (DateTime epoch);
        }

        public interface ICell<T> :  ICell, IObservable<T>, IValueCell<T>, ICoCell<T>
        {
            /// <summary>
            /// Provide a functor to calculate the cell's value
            /// </summary>
            /// <typeparam name="T"></typeparam>
            FSharpFunc<Unit, T> Fun { set; }
        }
    }
}
